class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right

if __name__ == '__main__':
    a = [5,4,8,11,None,13,4,7,2,None,None,None,None,1,None]
    #先补齐数组，长度必须为2^n-1个元素
    #第n行元素有2^(n-1)个，按顺序对应即可
    tree = []
    for i in range(len(a)):
        onenode = TreeNode(val=a[i])
        tree.append(onenode)
    n = len(tree)
    for i in range(n):
        if tree[i] == None:
            continue
        if i*2+1 < n and tree[i*2+1] != None :
            tree[i].left = tree[i*2+1]
        if i*2+2 < n and tree[i*2+2] != None:
            tree[i].right = tree[i*2+2]
    root = tree[0]
    print(root.right.left.val)